package com.card.game.playback;

import java.util.Date;
import java.util.List;
import java.util.Vector;

import com.card.game.BasePlayer;
import com.card.game.Card;
import com.card.game.Player;
import com.card.game.event.EventType;
import com.card.game.log.PlayerResult;
import com.card.game.room.RoomSetting;
import com.card.game.room.SHRoom;
import com.google.common.collect.Lists;
import com.xiaoao.net.utils.TimeUtils;

/**   
 * @Description: TODO(用一句话描述该文件做什么) 
 * @author siyunlong  
 * @date 2016年9月5日 下午1:36:58 
 * @version V1.0   
 */
public class Playback {
	protected String date;
	protected int roomId;
	protected int juNum;
	protected List<Role> roles = Lists.newArrayList();
	protected RoomSetting roomSetting;
	protected String zhuangId;
	protected Card jinCard;
	protected int sieve;
	protected List<BackEvent> eventList;
	protected List<PlayerResult> resultList;
	
	public Playback() {
		super();
	}

	public Playback(SHRoom room) {
		this.roomSetting = room.getRoomSetting();
		this.roomId = room.getId();
		this.eventList = Lists.newArrayList();
		this.sieve = room.sieve;
		this.zhuangId = room.getZhuangId();
		this.date = TimeUtils.ToString(new Date());
		this.juNum = room.playNum;
		this.jinCard = room.getJinPai();
	}
	
	public void initRole(SHRoom room) {
		Vector<BasePlayer> players = room.getPlayerList();
		for (int i = players.size()-1; i >= 0; i--) {
			roles.add(new Role((Player)players.get(i)));
		}
	}
	
	public void setResultList(List<PlayerResult> resultList) {
		this.resultList = resultList;
	}

	public void addBackEvent(EventType t,Player player,Card card) {
		if(EventType.Qipai != t) {
			card = null;
		}
		eventList.add(new BackEvent(player,t,card));
	}

	public List<PlayerResult> getResultList() {
		return resultList;
	}

	
}
